﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Engine.Sgml.Allocation {
    internal sealed class AncestorsIterator : INodeIterator {
        private SElement current;

        public SElement Current {
            get { return current; }
            }

        public bool MoveNext() {
            throw new NotSupportedException();
            }

        public bool MovePrevious() {
            if (current == null)
                return false;
            current = current.Parent;
            return current != null;
            }

        public void Reset(SElement element) {
            Guard.ArgumentNotNull(element, "element");
            if (element.Parent == null)
                throw new InvalidOperationException("Could not iterate through the root of a document tree.");
            current = element;
            }
        }
    }
